#!/bin/bash

INSTALLER="aptitude"
if ! which aptitude &> /dev/null
then
 INSTALLER="apt-get"
fi

if test `whoami` != "root" 
then
  echo "  Error: You need root priviledges to run this script."
  exit $FAILURE
fi

# These are the default files for (K)Ubuntu 10.04 LTS
DISTRO=Ubuntu
RELEASE=lucid
FILES="geany qjackctl libjack-dev \
       gitk git-core subversion meld openssh-server \
       octave3.2 gnuplot octave-audio octave-signal \
       g++ gdb ddd automake autoconf libfftw3-3 libfftw3-dev \
       sfftw-dev sndfile-tools libsndfile1-dev pulseaudio-module-jack \
       qt4-qmake qtcreator"


# Try to find better definitions for the packages used
if which lsb_release &> /dev/null
then
  DISTRO=`lsb_release -is`
  RELEASE=`lsb_release -cs`

  case "$DISTRO" in
  Debian)
    case "$RELEASE" in
    squeeze)
      echo "Using data for $DISTRO/$RELEASE"
      FILES="geany qjackctl libjack-jackd2-dev \
             libjack-jackd2-0 gitk git-core subversion meld \
             openssh-server pulseaudio-module-jack \
             octave3.2 gnuplot octave-audio octave-signal \
             g++ gdb ddd automake autoconf libfftw3-3 libfftw3-dev \
             sfftw-dev sndfile-tools libsndfile1-dev \
             qt4-qmake qtcreator"
      ;;
    *)
      echo "No particular specification for $DISTRO/$RELEASE"
      echo "Using squeeze data"
      FILES="geany qjackctl libjack-jackd2-dev \
             libjack-jackd2-0 gitk git-core subversion meld \
             openssh-server pulseaudio-module-jack \
             octave3.2 gnuplot octave-audio octave-signal \
             g++ gdb ddd automake autoconf libfftw3-3 libfftw3-dev \
             sfftw-dev sndfile-tools libsndfile1-dev \
             qt4-qmake qtcreator"
      ;;
    esac
    ;;
  Ubuntu)
    case "$RELEASE" in
    lucid)
      echo "Using data for $DISTRO/$RELEASE"
      FILES="geany qjackctl libjack-dev \
             gitk git-core subversion meld openssh-server \
             octave3.2 gnuplot octave-audio octave-signal \
             g++ gdb ddd automake autoconf libfftw3-3 libfftw3-dev \
             sfftw-dev sndfile-tools libsndfile1-dev pulseaudio-module-jack \
             qt4-qmake qtcreator"
      ;;
    natty)
      echo "Using data for $DISTRO/$RELEASE"
      FILES="geany qjackctl libjack-jackd2-dev \
             libjack-jackd2-0 gitk git-core subversion meld \
             openssh-server pulseaudio-module-jack \
             octave3.2 gnuplot octave-audio octave-signal \
             g++ gdb ddd automake autoconf libfftw3-3 libfftw3-dev \
             sfftw-dev sndfile-tools libsndfile1-dev \
             qt4-qmake qtcreator"
      ;;
    *)
      echo "No particular specification for $DISTRO/$RELEASE"
      echo "Using lucid data"
      ;;
    esac
    ;;
  *)
    echo "No particular specification for $DISTRO/$RELEASE"
    ;;
  esac
else
  echo "No particular specification for $DISTRO/$RELEASE"
fi

sudo $INSTALLER install $FILES
